<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.hz.model.Activity"%>
<%@page import="com.hz.control.ActivityControl"%>
<%@ page import="com.hz.util.ParamUtil"%>
<%@page import="com.hz.control.ApplyActControl"%>
<%@page import="com.hz.model.*"%>
<%@page import="com.hz.control.ActTypeControl"%>

<!DOCTYPE HTML>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="../../../css/active.css"/>
    <script type="text/javascript" src="../../../js/core.js"></script>
   <script type="text/javascript" src="../../common/js/WebCalendar.js"></script>
    <title>申请的活动</title>
  </head>
  
  <body>
  <h1 class='title pr'>申请的活动<a href='ApplyActivity_add_1.jsp'>申请</a></h1>
  <%
         request.setCharacterEncoding("utf-8");
         User cu = (User)session.getAttribute("user");
         String sActType ="";
         String sState = "";
         String sTime = "";
         String sUid = "";
  
          String search = request.getParameter("search");
          if(search!=null&&search.equals("1")){
          sUid=ParamUtil.getString(request,"userId","");
          sTime = ParamUtil.getString(request,"holdTime","");
          sState  = ParamUtil.getString(request,"state","");
          sActType=ParamUtil.getString(request,"actType","");
         
          session.setAttribute("sUid",sUid);
          session.setAttribute("sTime",sTime);
          session.setAttribute("sState",sState);
          session.setAttribute("sActType",sActType);
          }else{
            sActType = (String)session.getAttribute("sActType");
            sState = (String)session.getAttribute("sState");
            sTime = (String)session.getAttribute("sTime");
            sUid = (String)session.getAttribute("sUid");
          }
  %>
 
  <form action="ApplyActivities.jsp?search=1" method="post">
  
  <table class='apply'>
  <tr>
  <td width='45%'>所有类型:<select class='txt' name="actType">
  <option value="">-选择类型-</option>
  <%
       Collection<ActType> atps = ActTypeControl.getAllActTypes();
       Iterator<ActType> it = atps.iterator();
       while(it.hasNext()){
       ActType at =  it.next();
   %>
   <option value="<%=at.getId() %>" <%if(sActType!=null&&!sActType.equals("")&&sActType.equals(at.getId()+""))out.print("selected='selected'"); %>><%=at.getTypeName() %></option>
   <%} %>
   </select>
   </td>
   
  <td width='45%'>状态:<select style='width:265px;' class='sel' name="state">
  <option value="">--所有状态--</option>
  <option value="1" <%if(sState!=null&&!sState.equals("")&&sState.equals("1"))out.print("selected='selected'"); %>>已通过</option>
  <option value="2" <%if(sState!=null&&!sState.equals("")&&sState.equals("2"))out.print("selected='selected'"); %>>未通过</option>
  <option value="0" <%if(sState!=null&&!sState.equals("")&&sState.equals("0"))out.print("selected='selected'"); %>>待审核</option>
  </select>
  </td>
  
  <td rowspan='2' width='9%'><input class='btn' type="submit" value="提交"></td>
  </tr>
  <tr>
  <td>举办时间:<input style='width:238px;' class='txt' type="text"  name="holdTime" maxlength="100"  id="Text3" value="<%if(sTime!=null)out.print(sTime);%>" onclick="SelectDate(this,'yyyy-MM-dd')" readonly="true" style="cursor:pointer" />
  <td>申请人:<select style='width:265px;' class='sel' name="userId">
  <option value="">-所有的-</option>
  <option value="<%=cu.getId() %>" <%if(sUid!=null&&!sUid.equals("")&&sUid.equals(cu.getId()+""))out.print("selected='selected'"); %>>-我申请的-</option>
  </select></td>
  </tr>
  </table>
  </form>
  
  

  <form> 

<% 
	 int pages = ParamUtil.getInt(request, "pages", 1);
	int rowsPerPage = ParamUtil.getInt(request, "pageSize", 10);
	 Collection<ApplyAct> appacts =  ApplyActControl.getApplyActivities(sActType,sState,sTime,sUid,pages,rowsPerPage);
	 Iterator<ApplyAct>  itappacs = appacts.iterator();
	 while(itappacs.hasNext()){
	ApplyAct aa = itappacs.next();
%>
<section class='section'>
<h1>标签：<%=ActTypeControl.getActTypeName(aa.getActType()) %>、<%=aa.getObject() %>、<%=aa.getLeader() %>、<%if(aa.getState()==0) out.print("待审核");if(aa.getState()==1) out.print("通过");if(aa.getState()==2) out.print("不通过"); %></h1>
<p class='name pr'><a class='list' href="ApplyActDetail.jsp?actid=<%=aa.getId()%>"> <%=aa.getName()%></a>
<span class='time pa'><%if(aa.getHoldTime()!=null&&aa.getHoldTime().length()>10)out.print(aa.getHoldTime().substring(0,10));else if(aa.getHoldTime()!=null)out.print(aa.getHoldTime());%></span></p>
</section>
  <%} %>
 <label class='bottom'> 
  <%
     out.println(ApplyActControl.pageInstance.getToolsMenu(pages));
  %>
  </label>
  </form>
  </body>
</html>
